package com.xmall.service.impl;

import com.xmall.bean.bo.FeedbackBO;
import com.xmall.bean.table.User;
import com.xmall.mapper.FeedbackMapper;
import com.xmall.service.FeedbackService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @author Connor
 * @ClassName: FeedbackServiceImpl
 * @PackageName: com.xmall.service.impl
 * @date 2020/12/09
 * @Version 1.0
 */
@Service
public class FeedbackServiceImpl implements FeedbackService {

    @Autowired
    FeedbackMapper feedbackMapper;

    @Override
    public void insertFeedback(FeedbackBO feedbackBO) {
        User user = (User) SecurityUtils.getSubject().getPrincipal();
        HashMap<String, Object> map = new HashMap<>(16);
        map.put("userId", user.getId());
        map.put("username", user.getNickname());
        // TODO 获取status?，反馈信息是否已经回复
        feedbackMapper.insertFeedback(feedbackBO, map);
    }
}
